/*
 * Copyright (c) JoinQuant Development Team
 * Author: Huayong Kuang <kuanghuayong@joinquant.com>
 *
 */

#include <iostream>
#include <boost/bimap.hpp>

using namespace std;


#define BMAP boost::bimap


int main(void)
{
    //typedef boost::bimap<std::string, int> bimap;
    typedef BMAP<std::string, int> bimap;
    bimap persons;

    cout << persons.size() << endl;

    persons.insert(bimap::value_type("Boris", 31));
    persons.insert(bimap::value_type("Anton", 31));
    persons.insert(bimap::value_type("Caesar", 25));

    std::cout << persons.left.count("Boris") << std::endl;
    std::cout << persons.right.count(31) << std::endl;

    for (auto it = persons.begin(); it != persons.end(); ++it)
    std::cout << it->left << " has " << it->right << " legs\n";

    // 元素查找
    bimap::left_const_iterator it;
    it = persons.left.find( "Boris" ); // 注意有个 .left
    if ( it != persons.left.end( ) )   // 注意是 .left.end( )
        cout << it->first << it->second << endl;

    bimap::right_const_iterator it2;
    it2 = persons.right.find(
        25
    );
    if (it2 != persons.right.end())
        cout << it2->first << it2->second << endl;

    cout << persons.size() << endl;

    return 0;
}

